﻿//-----------------------------------------------------------------------
// <copyright file="ClassTest.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Common.Repository.Interfaces.DataInterfaces;
using GateShift.Common.Repository.Interfaces.Repositories;
using GateShift.Services.GameFramework.GameObjects;
using GateShift.Testing.Mockup.DataLayer;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace GateShift.Testing.Services.GameFramework.GameObjects
{
    /// <summary>
    /// Summary description for ClassTest
    /// </summary>
    [TestClass]
    public class ClassTest
    {
        #region Test Variables
        private Class _classData;
        private IClassData _data;
        private MockRepositoryFactory _factory;
        #endregion

        #region Test Properties
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }
        #endregion

        #region Test Initialization/Cleanup

        [TestInitialize]
        public void TestInitialize()
        {
            _factory = new MockRepositoryFactory();
            _data = new MockClass();

            MockRepositoryFactory.TestInitialize();

            // Set up basic load mocks
            MockRepositoryFactory.GetMock<IClassRepository>().Expect(item => item.Create()).Returns(_data);

            _classData = new Class(_factory);
        }

        [TestCleanup]
        public void TestCleanup()
        {
            MockRepositoryFactory.TestCleanup();
            _classData = null;
        }

        #endregion

        #region Name

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_Null()
        {
            _classData.Name = null;
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_Empty()
        {
            _classData.Name = string.Empty;
        }

        [TestMethod]
        [ExpectedException(typeof(FormatException))]
        public void Name_FirstPositionNumber()
        {
            _classData.Name = "1Name";
        }

        [TestMethod]
        [ExpectedException(typeof(IndexOutOfRangeException))]
        public void Name_TooLong()
        {
            _classData.Name = string.Empty.PadRight(21, 'A');
        }

        [TestMethod]
        [ExpectedException(typeof(FormatException))]
        public void Name_InvalidName()
        {
            _classData.Name = "!";
        }

        [TestMethod]
        [ExpectedException(typeof(FormatException))]
        public void Name_Spaces()
        {
            _classData.Name = "A Spaced Name";
        }

        [TestMethod]
        public void Name_Success()
        {
            const string TestData = "A123Thisisa123longna";
            _classData.Name = TestData;

            Assert.AreEqual(TestData, _data.Name);
        }

        #endregion

        #region ModifierAccuracy

        [TestMethod]
        public void ModifierAccuracy_Success()
        {
            _classData.ModifierAccuracy = 123;
            Assert.AreEqual(123, _data.ModifierAccuracy);
        }

        #endregion

        #region ModifierAccuracy

        [TestMethod]
        public void ModifierAgility_Success()
        {
            _classData.ModifierAgility = 123;
            Assert.AreEqual(123, _data.ModifierAgility);
        }

        #endregion

        #region ModifierEndurance

        [TestMethod]
        public void ModifierEndurance_Success()
        {
            _classData.ModifierEndurance = 123;
            Assert.AreEqual(123, _data.ModifierEndurance);
        }

        #endregion

        #region ModifierEnergy

        [TestMethod]
        public void ModifierEnergy_Success()
        {
            _classData.ModifierEnergy = 123;
            Assert.AreEqual(123, _data.ModifierEnergy);
        }

        #endregion

        #region ModifierForce

        [TestMethod]
        public void ModifierForce_Success()
        {
            _classData.ModifierForce = 123;
            Assert.AreEqual(123, _data.ModifierForce);
        }

        #endregion

        #region ModifierInsight

        [TestMethod]
        public void ModifierInsight_Success()
        {
            _classData.ModifierInsight = 123;
            Assert.AreEqual(123, _data.ModifierInsight);
        }

        #endregion

        #region ModifierIntellect

        [TestMethod]
        public void ModifierIntellect_Success()
        {
            _classData.ModifierIntellect = 123;
            Assert.AreEqual(123, _data.ModifierIntellect);
        }

        #endregion

        #region ModifierStrength

        [TestMethod]
        public void ModifierStrength_Success()
        {
            _classData.ModifierStrength = 123;
            Assert.AreEqual(123, _data.ModifierStrength);
        }

        #endregion

        #region ModifierWill

        [TestMethod]
        public void ModifierWill_Success()
        {
            _classData.ModifierWill = 123;
            Assert.AreEqual(123, _data.ModifierWill);
        }

        #endregion

        #region TotalAccuracy

        [TestMethod]
        public void TotalAccuracy_Success()
        {
            _data.ModifierAccuracy = 123;
            Assert.AreEqual(123, _classData.TotalAccuracy);
        }

        #endregion

        #region TotalAccuracy

        [TestMethod]
        public void TotalAgility_Success()
        {
            _data.ModifierAgility = 123;
            Assert.AreEqual(123, _classData.TotalAgility);
        }

        #endregion

        #region TotalEndurance

        [TestMethod]
        public void TotalEndurance_Success()
        {
            _data.ModifierEndurance = 123;
            Assert.AreEqual(123, _classData.TotalEndurance);
        }

        #endregion

        #region TotalEnergy

        [TestMethod]
        public void TotalEnergy_Success()
        {
            _data.ModifierEnergy = 123;
            Assert.AreEqual(123, _classData.TotalEnergy);
        }

        #endregion

        #region TotalForce

        [TestMethod]
        public void TotalForce_Success()
        {
            _data.ModifierForce = 123;
            Assert.AreEqual(123, _classData.TotalForce);
        }

        #endregion

        #region TotalInsight

        [TestMethod]
        public void TotalInsight_Success()
        {
            _data.ModifierInsight = 123;
            Assert.AreEqual(123, _classData.TotalInsight);
        }

        #endregion

        #region TotalIntellect

        [TestMethod]
        public void TotalIntellect_Success()
        {
            _data.ModifierIntellect = 123;
            Assert.AreEqual(123, _classData.TotalIntellect);
        }

        #endregion

        #region TotalStrength

        [TestMethod]
        public void TotalStrength_Success()
        {
            _data.ModifierStrength = 123;
            Assert.AreEqual(123, _classData.TotalStrength);
        }

        #endregion

        #region TotalWill

        [TestMethod]
        public void TotalWill_Success()
        {
            _data.ModifierWill = 123;
            Assert.AreEqual(123, _classData.TotalWill);
        }

        #endregion
    }
}